﻿#region

using SqlSugar;
using Vin.Tool.AspNetCore.Singleton;
using Vin.Tool.Attributes;

#endregion

namespace Vin.Extension.SqlSugar.Repository;

// [VinRepository]
[Service]
public class VinBaseRepository<TEntity> : SimpleClient<TEntity>, IVinBaseRepository<TEntity>
    where TEntity : class, new()
{
    /// <summary>
    /// 生成Id
    /// </summary>
    public long GetNextId()
    {
        return SnowFlakeSingle.Instance.NextId();
    }

    public VinBaseRepository(ISqlSugarClient? context = null) : base(context)
    {
        if (context == null)
        {
            this.Context = VinApp.GetRequiredServiceByHttpContext<ISqlSugarClient>();
        }

        VinApp.Inject(this);
    }
}